package br.com.kliptus.persistence;

import java.util.List;

import org.maverick.persistence.spring.jpa.PersistenceDefaultDAO;
import org.springframework.stereotype.Repository;

import br.com.kliptus.model.bean.CustomerJB;
import br.com.kliptus.model.bean.EntityTypeJB;
import br.com.kliptus.model.bean.FederalUnitJB;
import br.com.kliptus.persistence.dao.CustomerDAO;

@Repository("customerDAOImpl")
public class CustomerDAOImpl extends PersistenceDefaultDAO<CustomerJB> implements CustomerDAO {

	private static final long serialVersionUID = 1L;
	
	public CustomerDAOImpl() {
		super(CustomerJB.class);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<EntityTypeJB> getEntityTypeList() {
		return super.entityManager.createQuery(" select entityType from EntityTypeJB entityType ").getResultList();
	}

	@Override
	public EntityTypeJB getEntityTypeById(Long id) {
		return super.entityManager.find(EntityTypeJB.class, id);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<FederalUnitJB> getFederalUnitList() {
		return super.entityManager.createQuery(" select federalUnit from FederalUnitJB federalUnit order by federalUnit.symbol ").getResultList();
	}

}